package cn.jr.dao.impl;

import cn.jr.dao.IAccountDao;
import cn.jr.pojo.Account;
import cn.jr.util.DBHelper;

import java.util.ArrayList;

@SuppressWarnings("all")
//账户表
public class AccountDaoImpl implements IAccountDao {

    DBHelper db = new DBHelper();

    @Override //添加账户 -- accountId 不是自增，从tshoprun拿userId
    public int insertAccount(int userId) {
        String sql = "insert into taccount values(?,'0.00')";
        return db.dtUpdate(sql,userId);
    }

    @Override //更新余额 -- 拿 accountId 查找并给 accountMoney赋值
    public int updateAccount(int accountId, double addedMoney) {
        String sql = "update taccount set accountMoney=accountMoney+? where accountId=?";
        return db.dtUpdate(sql,addedMoney,accountId);
    }

    @Override //输入密码，查询账户总金额
    public ArrayList<Account> queryAccount() {
        String  sql = "select * from taccount";
        return db.dtQuery(sql,Account.class);
    }

    /*
    @Override//账户查询，输入密码查询账户总金额
    public ShopRun selectAccount(String accountPasswordInput) {
        String accountPassword  = "aaa123";
        if(accountPasswordInput.equals(accountPassword)){
            String sql = "select accountMoney from taccount where accountId=1 ";
            ArrayList<ShopRun> list = db.dtQuery(sql, ShopRun.class, accountPasswordInput);
            return list.get(0);
        }else{
            return new ShopRun();
        }
    }

    @Override//按时间统计，输入起止时间，返回这段时间账户收入金额--时间是订单详表里的？
    public Order selectAccount(String Starttime, String Endtime) {
        return null;
    }

    @Override
    public Order selectAccount(Order ordernumber) {
        return null;
    }*/


}
